package com.ap.core.validation.message.rules;

import com.ap.core.cxf.jaxb.common.ActivationStatus;
import com.ap.core.dao.ZappConsumerUserDao;
import com.ap.core.domain.ZappConsumerUser;
import com.ap.core.message.managepayment.info.RetrieveRTPMessageInfo;
import com.ap.core.validation.message.info.MessageValidationInfo;
import com.ap.core.validation.message.info.RTPOriginalInfo;
import com.ap.core.validation.rules.AbstractValidationRule;

/**
 * User: Ranjit.Singh Check if provided Bank Consumer ID is not active.
 */
public class RV0008Rule
		extends
		AbstractValidationRule<MessageValidationInfo<RetrieveRTPMessageInfo, RTPOriginalInfo>> {

	private ZappConsumerUserDao zappConsumerUserDao;

	@Override
	public boolean validate(
			MessageValidationInfo<RetrieveRTPMessageInfo, RTPOriginalInfo> infoObject) {

		ZappConsumerUser zappConsumerUser = zappConsumerUserDao
				.getZappConsumerUserByFiIdentificationAndFiCustomerId(
						infoObject.getBoundObject().getRequestInfo().getFIId(),
						infoObject.getBoundObject().getRequestInfo()
								.getFIConsumerId());

		return ActivationStatus.ACTIVE.equals(zappConsumerUser.getZappConsumerStatusCode());
	}

	public void setZappConsumerUserDao(ZappConsumerUserDao zappConsumerUserDao) {
		this.zappConsumerUserDao = zappConsumerUserDao;
	}
}
